package com.lyp.crm.conrtoller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lyp.crm.entity.Fenye;
import com.lyp.crm.entity.Journal;
import com.lyp.crm.service.Journaldao;

import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.annotations.ApiIgnore;
@Controller
@CrossOrigin(origins = "*")
public class journalController {
	@Autowired
	private Journaldao journaldao;
	@Autowired
	private Fenye<Journal> fenye;
	
	/**
	 * 多条件查询跟踪信息日志
	 * @param page
	 * @param rows
	 * @param sname
	 * @param uname
	 * @param joperate
	 * @param minqita
	 * @param maxqita
	 * @return 日志集合
	 */
	@ApiOperation(value="多条件查询日志", notes="根据 url 的各种数据 来获取跟踪信息日志的详细信息")
	@ApiImplicitParams({
		@ApiImplicitParam(name = "page", value = "分页参数", required = true, dataType = "Integer", paramType = "path"), 
		@ApiImplicitParam(name = "rows", value = "分页参数", required = true, dataType = "Integer", paramType = "path"), 
		@ApiImplicitParam(name = "sname", value = "学生姓名", required = true, dataType = "String", paramType = "path"), 
		@ApiImplicitParam(name = "uname", value = "员工姓名", required = true, dataType = "String", paramType = "path"), 
		@ApiImplicitParam(name = "joperate", value = "员工对学生的操作", required = true, dataType = "String", paramType = "path"), 
		@ApiImplicitParam(name = "minqita", value = "最小时间", required = true, dataType = "String", paramType = "path"), 
		@ApiImplicitParam(name = "maxqita", value = "最大时间", required = true, dataType = "String", paramType = "path") 
		
	})
	@ResponseBody
	@RequestMapping(value="/SelectJournal",method=RequestMethod.POST)
	public Fenye<Journal> SelectJournal(Integer page,Integer rows,String sname,String uname,String joperate,String minqita,String maxqita) {
		
		fenye.setSname(sname);
		fenye.setUname(uname);
	
		fenye.setJoperate(joperate);
		
		fenye.setMaxqita(maxqita);
	
		fenye.setMinqita(minqita);
		
		fenye.setPage((page-1)*rows);
	
		fenye.setPageSize(rows);
		fenye = journaldao.SelectJournal(fenye);
		return fenye;
	}
	
	
	
	/**
	 * 
	 * @param page
	 * @param rows
	 * @param sname
	 * @param uname
	 * @param joperate
	 * @param minqita
	 * @param maxqita
	 * @return
	 */
	@ApiIgnore
	@ResponseBody
	@RequestMapping(value="/SelectJournal1",method=RequestMethod.POST)
	public Fenye<Journal> SelectJournal1(Integer page,Integer rows,String sname,String uname,String joperate,String minqita,String maxqita) {
		fenye.setSname(sname);
		fenye.setUname(uname);
		fenye.setJoperate(joperate);
		fenye.setMaxqita(maxqita);
		fenye.setMinqita(minqita);
		fenye.setPage((page-1)*rows);
		fenye.setPageSize(rows);
		fenye = journaldao.SelectJournal1(fenye);
		return fenye;
	}
	
	/**
	 * 
	 * @param journal
	 * @return
	 */
	@ApiOperation(value="增加查询日志", notes="根据 url 的数据 来增加跟踪信息日志")
	@ApiImplicitParams({
		@ApiImplicitParam(name = "jdate", value = "日志时间", required = true, dataType = "String", paramType = "path"), 
		@ApiImplicitParam(name = "jstid", value = "学生id", required = true, dataType = "Integer", paramType = "path"), 
		@ApiImplicitParam(name = "jsname", value = "学生姓名", required = true, dataType = "String", paramType = "path"), 
		@ApiImplicitParam(name = "jusid", value = "员工id", required = true, dataType = "Integer", paramType = "path"), 
		@ApiImplicitParam(name = "juname", value = "员工姓名", required = true, dataType = "String", paramType = "path"), 
		@ApiImplicitParam(name = "jvisdate", value = "回访时间", required = true, dataType = "String", paramType = "path"), 
		@ApiImplicitParam(name = "jvisit", value = "回访方式", required = true, dataType = "String", paramType = "path"), 
		@ApiImplicitParam(name = "jreview", value = "回访情况", required = true, dataType = "String", paramType = "path"), 
		@ApiImplicitParam(name = "jtali", value = "跟踪方式", required = true, dataType = "String", paramType = "path"), 
		@ApiImplicitParam(name = "jnextdate", value = "下次跟踪时间", required = true, dataType = "String", paramType = "path"), 
		@ApiImplicitParam(name = "jremark", value = "备注", required = true, dataType = "String", paramType = "path"), 
		@ApiImplicitParam(name = "joperate", value = "操作", required = true, dataType = "String", paramType = "path"), 
		
	})
	@ResponseBody
	@RequestMapping(value="/insertJournal",method=RequestMethod.POST)
	public Integer insertJournal(Journal journal) {
		
		return journaldao.insertJournal(journal);
	}
	/**
	 * 
	 * @param jid
	 * @return
	 */
	@ApiOperation(value="删除查询日志", notes="根据 url 的id来删除跟踪信息日志")
	@ApiImplicitParam(name = "jid", value = "日志id时间", required = true, dataType = "String", paramType = "path")
	@ResponseBody
	@RequestMapping(value="/delectJournal",method=RequestMethod.POST)
	public Integer deleteJournal(Integer jid) {
	
		return journaldao.deleteJournal(jid);
	}
	/**
	 * 
	 * @param journal
	 * @return
	 */
	@ApiIgnore
	@ResponseBody
	@RequestMapping(value="/SelectChakanJournal",method=RequestMethod.POST)
	public Fenye<Journal> SelectChakanJournal(Journal journal) {
	fenye.setT(journal);
	System.out.println(fenye);
	fenye = journaldao.SelectJournal(fenye);
	return fenye;
	}
}
